import type { R, TableDataInfo } from '@/api/model/resultModel';
import type { XyywShoppingCartForm, XyywShoppingCartQuery, XyywShoppingCartVo } from '@/api/xyyw/model/shoppingCartModel';
import { request } from '@/utils/request';

// 查询购物车列表
export function listShoppingCart(query?: XyywShoppingCartQuery) {
  return request.get<TableDataInfo<XyywShoppingCartVo>>({
    url: '/xyyw/shoppingCart/list',
    params: query,
  });
}

// 查询购物车详细
export function getShoppingCart(shoppingCartId: number) {
  return request.get<R<XyywShoppingCartVo>>({
    url: `/xyyw/shoppingCart/${shoppingCartId}`,
  });
}

// 新增购物车
export function addShoppingCart(data: XyywShoppingCartForm) {
  return request.post<R<void>>({
    url: '/xyyw/shoppingCart',
    data,
  });
}

// 修改购物车
export function updateShoppingCart(data: XyywShoppingCartForm) {
  return request.put<R<void>>({
    url: '/xyyw/shoppingCart',
    data,
  });
}

// 删除购物车
export function delShoppingCart(shoppingCartIds: number | Array<number>) {
  return request.delete<R<void>>({
    url: `/xyyw/shoppingCart/${shoppingCartIds}`,
  });
}
